import { customColumns } from '../demo/jeecg/erplist/erplist.data';
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';

//列表数据
export const columns: BasicColumn[] = [
  {
    title: 'ID',
    align: 'center',
    dataIndex: 'id',
    width: 100,
    resizable: true,
    slots: { customRender: 'ID' },
  },
  {
    title: '激活原因',
    align: 'center',
    dataIndex: 'reason',
    width: 240,
    resizable: true,
    slots: { customRender: 'reason' },
  },
  {
    title: '备注',
    align: 'center',
    dataIndex: 'remark',
    resizable: true,
  },

  {
    title: '券图片',
    align: 'center',
    dataIndex: 'cardTypeId_dictText',
    slots: { customRender: 'isShow' },
    width: 200,
    resizable: true,
  },
  {
    title: '卡种名称',
    align: 'center',
    dataIndex: 'cardTypeId_dictText',
    width: 200,
    resizable: true,
  },
  {
    title: '使用状态',
    align: 'center',
    dataIndex: 'useState_dictText',
    width: 100,
    resizable: true,
  },
  {
    title: '渠道来源',
    align: 'center',
    dataIndex: 'cardSourceId_dictText',
    width: 120,
    resizable: true,
  },
  {
    title: '进货价',
    align: 'center',
    dataIndex: 'buyPrice',
    width: 80,
    resizable: true,
  },
  {
    title: '会员ID',
    align: 'center',
    dataIndex: 'memberId',
    resizable: true,
  },
  // {
  //   title: '是否标记优先',
  //   align: 'center',
  //   dataIndex: 'isPriority_dictText',
  // },
  {
    title: '商品名称',
    align: 'center',
    dataIndex: 'name',
    resizable: true,
  },
  {
    title: '订单号',
    align: 'center',
    dataIndex: 'orderId',
    resizable: true,
  },
  {
    title: '失效时间',
    align: 'center',
    dataIndex: 'lifespan',
    resizable: true,
  },
  {
    title: '删除原因',
    dataIndex: 'delReason',
    align: 'center',
    resizable: true,
  },
  {
    title: '删除操作人',
    dataIndex: 'delOperator',
    align: 'center',
    resizable: true,
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '卡种/品牌名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '激活原因',
    field: 'reason',
    component: 'Input',
  },

  {
    label: '使用状态',
    field: 'useState',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'card_use_state',
    },
  },
  {
    label: '会员ID/券码ID',
    field: 'memberId',
    component: 'Input',
  },
  {
    label: '卡券ID',
    field: 'id',
    component: 'Input',
  },
  {
    label: '渠道来源',
    field: 'cardSourceId',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_card_source,name,id',
    },
  },
  {
    label: '类型',
    field: 'cardStyleId',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_card_style,name,id',
    },
  },
  {
    field: 'createTime',
    label: '失效日期',
    component: 'RangePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
    },
  },
  // {
  //   label: '状态',
  //   field: 'state',
  //   component: 'JDictSelectTag',
  //   componentProps: {
  //     dictCode: 'card_state',
  //   },
  // },

  // {
  //   label: '失效时间',
  //   field: 'dateTimeRangeSelect',
  //   component: 'RangePicker',
  //   componentProps: {
  //     //是否显示时间
  //     showTime: true,
  //     //日期格式化
  //     format: 'YYYY/MM/DD',
  //     //范围文本描述用集合
  //     placeholder: ['请选择开始日期时间', '请选择结束日期时间'],
  //   },
  // },
  {
    label: '券码',
    field: 'code',
    component: 'Input',
  },
    {
    label: '删除人',
    field: 'delOperator',
    component: 'Input',
  },

];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '卡种',
    field: 'cardTypeId',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_card_typ,name,id',
    },
    dynamicDisabled: true,
  },
  {
    label: '兑换码',
    field: 'code',
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '券码',
    field: 'couponCode',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 1,
    },
    dynamicDisabled: true,
  },
  {
    label: '使用状态',
    field: 'useState',
    defaultValue: '0',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'card_use_state',
    },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入使用状态!' }];
    },
    dynamicDisabled: true,
  },
  {
    label: '使用时间',
    field: 'useTime',
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '上传用户',
    field: 'memberId',
    defaultValue: 'admin',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_member,nick_name,id',
    },
    dynamicDisabled: true,
  },
  {
    label: '状态',
    field: 'state',
    defaultValue: '1',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'card_state',
    },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入状态!' }];
    },
  },
  {
    label: '上架状态',
    field: 'groundingState',
    defaultValue: '1',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'card_grounding',
    },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入上架状态!' }];
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  code: { title: '兑换码', order: 0, view: 'text', type: 'string' },
  couponCode: { title: '券码', order: 1, view: 'image', type: 'string' },
  useState: { title: '使用状态', order: 2, view: 'list', type: 'string', dictCode: 'card_use_state' },
  memberId: { title: '上传用户', order: 3, view: 'list', type: 'string', dictTable: 'app_member', dictCode: 'id', dictText: 'nick_name' },
  useTime: { title: '使用时间', order: 4, view: 'datetime', type: 'string' },
  state: { title: '状态', order: 5, view: 'list', type: 'string', dictCode: 'card_state' },
  groundingState: { title: '上架状态', order: 6, view: 'list', type: 'string', dictCode: 'card_grounding' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
